package com.vertexnet.realestatenet.model.bean;

// Generated May 22, 2012 8:11:57 AM by Hibernate Tools 3.4.0.CR1

import java.util.HashSet;
import java.util.Set;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import static javax.persistence.GenerationType.IDENTITY;
import javax.persistence.Id;
import javax.persistence.OneToMany;
import javax.persistence.Table;

import org.apache.commons.lang.builder.EqualsBuilder;
import org.apache.commons.lang.builder.HashCodeBuilder;

/**
 * Area generated by hbm2java
 */
@Entity
@Table(name = "area", catalog = "real_estate_net")
public class Area implements java.io.Serializable {

	private static final long serialVersionUID = 1L;
	private Integer areaId;
	private String areaName;
	private Set<Customer> customers = new HashSet<Customer>(0);

	public Area() {
	}

	public Area(String areaName) {
		this.areaName = areaName;
	}

	public Area(String areaName, Set<Customer> customers) {
		this.areaName = areaName;
		this.customers = customers;
	}

	@Id
	@GeneratedValue(strategy = IDENTITY)
	@Column(name = "area_id", unique = true, nullable = false)
	public Integer getAreaId() {
		return this.areaId;
	}

	public void setAreaId(Integer areaId) {
		this.areaId = areaId;
	}

	@Column(name = "area_name", nullable = false, length = 25)
	public String getAreaName() {
		return this.areaName;
	}

	public void setAreaName(String areaName) {
		this.areaName = areaName;
	}

	@OneToMany(fetch = FetchType.LAZY, mappedBy = "area")
	public Set<Customer> getCustomers() {
		return this.customers;
	}

	public void setCustomers(Set<Customer> customers) {
		this.customers = customers;
	}

	@Override
	public String toString() {
		return areaName;
	}

	@Override
	public boolean equals(Object obj) {
		if(obj == null) {
			return false;
		}
		if(obj instanceof Area) {
			Area area = (Area) obj;
			return new EqualsBuilder()
			.append(this.getAreaId(), area.getAreaId())
			.append(this.getAreaName(), area.getAreaName())
			.isEquals();
		}
		return false;
	}

	@Override
	public int hashCode() {
		return new HashCodeBuilder()
		.append(this.getAreaId())
		.append(this.getAreaName())
		.toHashCode();
	}
}
